The Gaussian, its even moments and the error functions are integrated - #1512
Merged
Merged
Conversation
int F^(a x^2 + b x + c) dx is F^(c - b^2/(4a)) times the Gaussian of A = a ln F in u = x + b/(2a), and int e^(A u^2) du is sqrt(pi)/(2 sqrt(-A)) erf(sqrt(-A) u), written with erfi and the real root where A is decidably positive. Beside an even power of x, on either side of 0, parts reduce it two powers at a time to the Gaussian; an odd power ends at an elementary integral or at the exponential integral and is not taken. erf, erfc and erfi are integrated by parts against 1. Part of #1501. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
…x and e^(x^3) The documented example of Integrate(string), the transformation tests and the exponential ansatz's declined row used e^(x^2) as the integral with no answer; it is sqrt(pi)/2 erfi(x) now. They use x^x, which has no antiderivative in any function the library will have, and e^(x^3) where the row is about the ansatz's shape. y' + y = e^(x^2) moves from what the ODE solver declines to what it solves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
With #1509, a definite integral takes the limit where its antiderivative is undefined at a bound, so the moments' x^k e^(-x^2) at +oo is 0 and the half line gives sqrt(pi)/2, sqrt(pi)/4 and 3 sqrt(pi)/8. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
This was referenced Sep 27, 2026
Merged
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1501, step 3.
These are the first integration rules that answer in the error functions. Each is a closed form that names the identity it uses, and none of them is a fallback for an elementary search that failed.
The Gaussian.
int F^(a x^2 + b x + c) dxis an error function of the completed square. The square isa (x + b/(2a))^2 + c - b^2/(4a), so withA = a ln Fandu = x + b/(2a)the integral isF^(c - b^2/(4a))timesint e^(A u^2) du, andint e^(A u^2) du = sqrt(pi)/(2 sqrt(-A)) erf(sqrt(-A) u). That differentiates back for every non-zeroA, whichever root is taken. WhereAis decidably positive the answer useserfiand the real root instead. Soe^(-x^2)givessqrt(pi)/2 erf(x), ande^(x^2)givessqrt(pi)/2 erfi(x).The Gaussian beside an even power of
x.int x^m F^(a x^2 + c) dx, for an evenmon either side of 0, reduces two powers at a time to the Gaussian:I_m = x^(m - 1) e^(A x^2)/(2A) - (m - 1)/(2A) I_(m - 2);m.An odd
mends at an elementary integral, which is answered elsewhere, or at the exponential integral, so it isn't taken here.The error functions themselves, by parts against 1:
int erf(u) = u erf(u) + e^(-u^2)/sqrt(pi), and likewise forerfcanderfi.A symbolic exponent is answered for the generic case, as
F^(a x)/(a ln F)already is.f^(a + b x^2)givesf^a sqrt(pi)/(2 sqrt(-b ln f)) erf(sqrt(-b ln f) x)with no condition attached.Together with the error functions' values at
±oo(#1506), the whole-line integrals come out exactly:e^(-x^2)over the line issqrt(pi), ande^(-x^2/2)issqrt(2 pi).Two implementation notes
erfireadsEvaled, as the integrator's other sign tests do. It is in one place, and all of them move together to the interval evaluation of The integrator's sampled-point checks evaluate in intervals, which read no setting #1497.Measured
The corpus runs and the gate were taken at
f6f747e3, the change before its rebase onto #1509 and #1510, neither of which changes an indefinite integral.Rubi's problems whose answer uses
erf,erfcorerfi: 811 across families 0 to 7, graded by differentiating the answer back, at a 3 s budget.c42ec55eBy Rubi section:
Every problem in 2.1, 2.2, 6.1.1, 6.2.1, 7.1.2, 7.1.4, 7.1.5, 7.2.2, 7.2.4 and 7.3.4 is now solved, and so are the four textbook problems. Most reach the Gaussian through a substitution the integrator already makes. The sections still at 0 are the next seams: 3.1.2 (a power of a logarithm beside a power of
x), 4.7.6 (an exponential of a quadratic times a trigonometric function of one) and 5.1.5.The textbook suites (family 0): all 1892 problems at a 5 s budget. Counting
erf,erfcanderfias functions the library has makes four more problems fair, 1778 from 1774. Hearn 337 and 338 haveerfin the integrand. Hearn 191 and Moses 74, bothe^(x^2), need it in the answer.c42ec55eThe four gained are those four, and no problem master solves is lost.
The unit suite passes on net10.0: 12874 passed, 14 skipped, none failed, of 12888, at
30662d38. Its first run failed seven tests. Each usede^(x^2)as the example of an integral with no answer: the documented example ofIntegrate(string), three transformation tests, the exponential ansatz's declined row, and the ODE solver's declined row. Those now usex^x, which has no antiderivative in any function the library will have, ande^(x^3)where the row is about the ansatz's shape.y' + y = e^(x^2)moves to what the ODE solver solves.The allocation gate passes on all 19 gated benchmarks.
With #1509 on master, the half line comes out too:
e^(-x^2),x^2 e^(-x^2)andx^4 e^(-x^2)over[0, +oo)aresqrt(pi)/2,sqrt(pi)/4and3 sqrt(pi)/8.🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura